﻿<%@ WebHandler Language="C#" Class="confirmRequestChange" %>

using System;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Chenxin.Lib.Utility;

public class confirmRequestChange : AjaxHandlerBase
{

    public confirmRequestChange()
    {
        //查看请求
        htTypePermit.Add("view", Constants.Permit_RequestView);
        //请求变更
        htTypePermit.Add("add", Constants.Permit_RequestChange);
        //否决请求变更
        htTypePermit.Add("refuse", Constants.Permit_RequestVeto);
        //否决请求变更
        htTypePermit.Add("confirm", Constants.Permit_RequestConfirm);
    }

    override public void RequestProcess(HttpContext context)
    {
        context.Response.AddHeader("pragma", "no-cache");
        context.Response.AddHeader("cache-control", "");
        context.Response.CacheControl = "no-cache";
        
        string strOp = context.Request["op"];
        string strResponse = "";
        switch (strOp.ToLower())
        {
            case "add":
                strResponse = insert(context);
                break;
            case "validate":
                strResponse = validate(context);
                break;
            case "getmodel":
                strResponse = getData(context);
                break;
            case "getinfo":
                strResponse = getConfirmData(context);
                break;
            case "confirm":
                strResponse = update(context);
                break;
            case "refuse":
                strResponse = refuse(context);
                break;
            case "getlist":
                strResponse = search(context);
                break;
            case "edit":
                strResponse = EditHouseStatus(context);
                break;
            case "getrequestlist":
                getHouseRequestList(context);
                break;
            case "gethouseinfo":
                strResponse = GetHouseInfo(context);
                break;
            default:
                break;
        }
        context.Response.Write(strResponse);
    }
    //*******************************************
    //功能概要       ：获得房源信息
    //参数説明       ：RecordId 主键 
    //返回值説明     ：void
    //功能詳細       ：初始化
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string GetHouseInfo(HttpContext context)
    {
        try
        {
            //转换成实体
            string recordId = context.Request["requestid"];
            if (String.IsNullOrEmpty(recordId))
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求标识丢失，请联系管理员！");
            Chenxin.Lib.House.Entity.House_RequestChangeInfo house_RequestChangeInfo = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetModel(new Guid(recordId));
            Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(house_RequestChangeInfo.HouseId);
            if (house_BaseInfo == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源信息丢失，请联系管理员！");
            return string.Format("{{success:'1',msg:'成功',data:{{requestinfo:{0},status:{1}}}}}", Chenxin.Lib.Utility.JsonHelp.Convert2Json(house_BaseInfo), house_BaseInfo.Status);
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }
    //*******************************************
    //功能概要       ：初始化
    //参数説明       ：RecordId 主键 
    //返回值説明     ：void
    //功能詳細       ：初始化
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string getData(HttpContext context)
    {
        try
        {
            //转换成实体
            string recordId = context.Request["requestid"];
            if (String.IsNullOrEmpty(recordId))
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求标识丢失，请联系管理员！");

            //向申请变更表中添加记录
            Chenxin.Lib.House.Entity.House_RequestChangeInfo house_RequestChangeInfo = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetModel(new Guid(recordId));
            return string.Format("{{success:'1',msg:'成功',data:{{requestinfo:{0}}}}}", Chenxin.Lib.Utility.JsonHelp.Convert2Json(house_RequestChangeInfo));
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }

    //*******************************************
    //功能概要       ：初始化
    //参数説明       ：RecordId 主键 
    //返回值説明     ：void
    //功能詳細       ：初始化
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string getConfirmData(HttpContext context)
    {
        try
        {
            //转换成实体
            string recordId = context.Request["requestid"];
            if (String.IsNullOrEmpty(recordId))
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求标识丢失，请联系管理员！");
            Chenxin.Lib.House.Entity.House_RequestChangeInfo house_RequestChangeInfo = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetModel(new Guid(recordId));
            Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(house_RequestChangeInfo.HouseId);
            if (house_BaseInfo == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源信息丢失，请联系管理员！");
            return string.Format("{{success:'1',msg:'成功',data:{{requestinfo:{0},status:{1}}}}}", Chenxin.Lib.Utility.JsonHelp.Convert2Json(house_RequestChangeInfo), house_BaseInfo.Status);
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }
    //*******************************************
    //功能概要       ：确认请求
    //参数説明       ：houseid 房源主键 requestStyle 请求方式 RequestChangeStyle状态变更 personId 所属人变更 txtSummary 请求说明
    //返回值説明     ：void
    //功能詳細       ：确认请求
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string update(HttpContext context)
    {
        try
        {
            //转换成实体
            Chenxin.Lib.House.Entity.House_RequestChangeInfo model = (Chenxin.Lib.House.Entity.House_RequestChangeInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.House.Entity.House_RequestChangeInfo));
            if (model.RecordId == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求标识丢失，请联系管理员！");
            if (model.HouseId == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源标识丢失，请联系管理员！");
            }
            Chenxin.Lib.House.Entity.House_RequestChangeInfo info = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetModel(model.RecordId);
            if (info == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求信息丢失，请联系管理员！");
            }
            Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(model.HouseId);
            int temp = Convert.ToInt32(house_BaseInfo.Status);
            if (house_BaseInfo == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源信息丢失，请联系管理员！");
            }
            Chenxin.Lib.House.Entity.Customer_BaseInfo customer_BaseInfo = Chenxin.Lib.House.DAL.Customer_BaseInfo.GetModel(house_BaseInfo.CustomerId);
            if (customer_BaseInfo == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "用户信息丢失，请联系管理员！");
            }
            
            info.DealTime = DateTime.Now;
            info.Status = 1;
            info.confirmPersonName = CurrentUserInfo.UserName;
            info.confirmPersonId = CurrentUserInfo.UserId;
            info.confirmDepartId = CurrentUserInfo.DepartId;
            info.confirmDepartName = CurrentUserInfo.DepartName;
            info.ResonRemarks = model.ResonRemarks;
            Chenxin.Lib.House.BLL.House_RequestChangeInfo.Update(info);

            Chenxin.Lib.House.Entity.House_BaseInfo_BakCol house_BaseInfo_BakCol = new Chenxin.Lib.House.Entity.House_BaseInfo_BakCol();
            house_BaseInfo_BakCol.RecordId = Guid.NewGuid();
            house_BaseInfo_BakCol.HouseId = house_BaseInfo.HouseId;
            Chenxin.Lib.House.Entity.Customer_BaseInfo_BakCol customer_BaseInfo_BakCol = new Chenxin.Lib.House.Entity.Customer_BaseInfo_BakCol();
            customer_BaseInfo_BakCol.RecordId = Guid.NewGuid();
            customer_BaseInfo_BakCol.CustomerId = customer_BaseInfo.CustomerId;
            //更新记录
            house_BaseInfo.IsNeedTran = false;
            if (model.ChangeType == 10)
            {
                house_BaseInfo_BakCol.ColumnName = "Status";
                house_BaseInfo_BakCol.ColumnDesc = "状态";
                house_BaseInfo_BakCol.OldValue = house_BaseInfo.Status.ToString();
                house_BaseInfo_BakCol.NewValue = model.HouseStatus.ToString();
                house_BaseInfo_BakCol.ChangeDesc = string.Format("状态由{0}改为：{1}", GetString(house_BaseInfo.Status), GetString(model.Status));
                house_BaseInfo.Status = Convert.ToInt32(model.HouseStatus);
            }
            else if (model.ChangeType == 20)
            {
                house_BaseInfo_BakCol.ColumnName = "OprPerson";
                house_BaseInfo_BakCol.ColumnDesc = "所属人";
                house_BaseInfo_BakCol.OldValue = "公司："+house_BaseInfo.CompanyName +" 部门："+ house_BaseInfo.OprDepart +" 业务员："+house_BaseInfo.OprPerson;
                Chenxin.Lib.Passport.Entity.Hr_UserInfo user = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(model.RequestUserCode);
                if (user != null)
                {
                    house_BaseInfo.CompanyName = user.CompanyName;
                    house_BaseInfo.CompanyId = user.CompanyId;
                    house_BaseInfo.CityId = user.CityId;
                    house_BaseInfo.OprDepart = user.DepartName;
                    house_BaseInfo.OprDepartId = user.DepartId;
                    house_BaseInfo.OprPerson = user.UserName;
                    house_BaseInfo.OprPersonId = user.UserId;
                    
                    house_BaseInfo_BakCol.NewValue = "公司："+house_BaseInfo.CompanyName +" 部门："+ house_BaseInfo.OprDepart +" 业务员："+house_BaseInfo.OprPerson;
                    house_BaseInfo_BakCol.ChangeDesc = string.Format("房源所属由{0}改为：{1}", house_BaseInfo_BakCol.OldValue, house_BaseInfo_BakCol.NewValue);

                    //customer_BaseInfo_BakCol.ColumnName = "person,customer";
                    //customer_BaseInfo_BakCol.ColumnDesc = "所属人，客户信息";
                    //customer_BaseInfo_BakCol.OldValue = "公司：" + customer_BaseInfo.CompanyName + " 部门：" + customer_BaseInfo.OprDepart + " 业务员：" + customer_BaseInfo.OprPerson + "电话：" + customer_BaseInfo.Phone + "手机：" + customer_BaseInfo.Mobile + "客户姓名：" + customer_BaseInfo.CustomerName;

                    //新增客户日志方法 by  tianno  2011-1-13*********************
                    //判断客户姓名是否被修改
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.CustomerName, customer_BaseInfo.CustomerName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CustomerName", "客户姓名", customer_BaseInfo.CustomerName, model.CustomerName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //城市
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.CityName, customer_BaseInfo.CityName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CityName", "城市", customer_BaseInfo.CityName, user.CityName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //公司
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.CompanyName, customer_BaseInfo.CompanyName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CompanyName", "公司", customer_BaseInfo.CompanyName, user.CompanyName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //部门
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.DepartName, customer_BaseInfo.OprDepart))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprDepart", "部门", customer_BaseInfo.OprDepart, user.DepartName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //人员
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.UserName, customer_BaseInfo.OprPerson))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprPerson", "人员", customer_BaseInfo.OprPerson, user.UserName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //手机
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Mobile, customer_BaseInfo.Mobile))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Mobile", "手机号码", customer_BaseInfo.Mobile, model.Mobile, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //判断联系电话是否被修改
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Phone, customer_BaseInfo.Phone))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Phone", "联系电话", customer_BaseInfo.Phone, model.Phone, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }

                    //***********************************************************
                    
                    
                    
                    customer_BaseInfo.CustomerName = model.CustomerName;
                    customer_BaseInfo.Mobile = model.Mobile;
                    customer_BaseInfo.Phone = model.Phone;
                    customer_BaseInfo.OprDepart = user.DepartName;
                    customer_BaseInfo.OprDepartId = user.DepartId;
                    customer_BaseInfo.OprPerson = user.UserName;
                    customer_BaseInfo.OprPersonId = user.UserId;
                    customer_BaseInfo.CityId = user.CityId;
                    customer_BaseInfo.CityName = user.CityName;
                    customer_BaseInfo.CompanyName = user.CompanyName;
                    customer_BaseInfo.CompanyId = user.CompanyId;
                    //customer_BaseInfo_BakCol.NewValue = "公司：" + customer_BaseInfo.CompanyName + "部门：" + customer_BaseInfo.OprDepart + " 业务员：" + customer_BaseInfo.OprPerson + " 电话：" + customer_BaseInfo.Phone + " 手机：" + customer_BaseInfo.Mobile + " 客户姓名：" + customer_BaseInfo.CustomerName;
                    //customer_BaseInfo_BakCol.ChangeDesc = string.Format("客户信息由{0}改为：{1}", customer_BaseInfo_BakCol.OldValue, customer_BaseInfo_BakCol.NewValue);
                 }
                Chenxin.Lib.House.DAL.Customer_BaseInfo.Update(customer_BaseInfo);
            }
            else if (model.ChangeType == 30)
            {
                house_BaseInfo_BakCol.ColumnName = "Person,Status";
                house_BaseInfo_BakCol.ColumnDesc = "所属人,状态";
                house_BaseInfo_BakCol.OldValue = "公司：" + house_BaseInfo.CompanyName + " 部门：" + house_BaseInfo.OprDepart + " 业务员：" + house_BaseInfo.OprPerson + " 状态：" + GetString(house_BaseInfo.Status);

                //customer_BaseInfo_BakCol.ColumnName = "person,customer";
                //customer_BaseInfo_BakCol.ColumnDesc = "所属人，客户信息";
                //customer_BaseInfo_BakCol.OldValue = "公司：" + customer_BaseInfo.CompanyName + " 部门：" + customer_BaseInfo.OprDepart + " 业务员：" + customer_BaseInfo.OprPerson + " 电话：" + customer_BaseInfo.Phone + " 手机：" + customer_BaseInfo.Mobile + " 客户姓名：" + customer_BaseInfo.CustomerName;

                //新增客户日志方法 by  tianno  2011-1-13*********************
                //判断客户姓名是否被修改
                if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.CustomerName, customer_BaseInfo.CustomerName))
                {
                    Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CustomerName", "客户姓名", customer_BaseInfo.CustomerName, model.CustomerName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                }
                //手机
                if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Mobile, customer_BaseInfo.Mobile))
                {
                    Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Mobile", "手机号码", customer_BaseInfo.Mobile, model.Mobile, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                }
                //判断联系电话是否被修改
                if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Phone, customer_BaseInfo.Phone))
                {
                    Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Phone", "联系电话", customer_BaseInfo.Phone, model.Phone, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                }
                //***********************************************************
                
                customer_BaseInfo.CustomerName = model.CustomerName;
                customer_BaseInfo.Mobile = model.Mobile;
                customer_BaseInfo.Phone = model.Phone;
                Chenxin.Lib.Passport.Entity.Hr_UserInfo userinfo = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(model.RequestUserCode);
                if (userinfo != null)
                {
                    //新增客户日志方法 by  tianno  2011-1-13*********************                    
                    //城市
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.CityName, customer_BaseInfo.CityName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CityName", "城市", customer_BaseInfo.CityName, userinfo.CityName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //公司
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.CompanyName, customer_BaseInfo.CompanyName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CompanyName", "公司", customer_BaseInfo.CompanyName, userinfo.CompanyName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //部门
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.DepartName, customer_BaseInfo.OprDepart))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprDepart", "部门", customer_BaseInfo.OprDepart, userinfo.DepartName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //人员
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.UserName, customer_BaseInfo.OprPerson))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprPerson", "人员", customer_BaseInfo.OprPerson, userinfo.UserName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //***********************************************************
                    
                    customer_BaseInfo.OprDepart = userinfo.DepartName;
                    customer_BaseInfo.OprDepartId = userinfo.DepartId;
                    customer_BaseInfo.OprPerson = userinfo.UserName;
                    customer_BaseInfo.OprPersonId = userinfo.UserId;
                    customer_BaseInfo.CityId = userinfo.CityId;
                    customer_BaseInfo.CityName = userinfo.CityName;
                    customer_BaseInfo.CompanyName = userinfo.CompanyName;
                    customer_BaseInfo.CompanyId = userinfo.CompanyId;
           
                    Chenxin.Lib.House.DAL.Customer_BaseInfo.Update(customer_BaseInfo);
                    house_BaseInfo.CompanyName = userinfo.CompanyName;
                    house_BaseInfo.CompanyId = userinfo.CompanyId;
                    house_BaseInfo.CityId = userinfo.CityId;
                    house_BaseInfo.OprDepart = userinfo.DepartName;
                    house_BaseInfo.OprDepartId = userinfo.DepartId;
                    house_BaseInfo.OprPerson = userinfo.UserName;
                    house_BaseInfo.OprPersonId = userinfo.UserId;
                    house_BaseInfo.Status = Convert.ToInt32(model.HouseStatus);
                    house_BaseInfo_BakCol.NewValue = "公司：" + house_BaseInfo.CompanyName + " 部门：" + house_BaseInfo.OprDepart + " 业务员：" + house_BaseInfo.OprPerson + " 状态：" + GetString(house_BaseInfo.Status);
                    house_BaseInfo_BakCol.ChangeDesc = string.Format("房源所属由{0}改为：{1}", house_BaseInfo_BakCol.OldValue, house_BaseInfo_BakCol.NewValue);
                
                    //customer_BaseInfo_BakCol.NewValue = "公司：" + customer_BaseInfo.CompanyName + " 部门：" + customer_BaseInfo.OprDepart + " 业务员：" + customer_BaseInfo.OprPerson + " 电话：" + customer_BaseInfo.Phone + " 手机：" + customer_BaseInfo.Mobile + " 客户姓名：" + customer_BaseInfo.CustomerName;
                    //customer_BaseInfo_BakCol.ChangeDesc = string.Format("客户信息由{0}改为：{1}", customer_BaseInfo_BakCol.OldValue, customer_BaseInfo_BakCol.NewValue);
                }
            }

            //记录状态更改
            if (null != model.HouseStatus && !model.HouseStatus.Equals(temp))
            {
                Chenxin.Lib.House.Entity.ChangeLog log = new Chenxin.Lib.House.Entity.ChangeLog();
                log.RecordId = Guid.NewGuid();
                log.HouseId = house_BaseInfo.HouseId;
                log.OperaterCode = CurrentUserInfo.UserCode;
                log.HouseCode = model.HouseCode;
                log.HouseAddress = house_BaseInfo.DetailAddress;
                log.ChangTime = DateTime.Now;
                log.Operater = CurrentUserInfo.UserName;
                log.OperaterId = CurrentUserInfo.UserId;
                log.OprDepartId = CurrentUserInfo.DepartId;
                log.OprDepart = CurrentUserInfo.DepartName;
                log.OprCompanyId = CurrentUserInfo.CompanyId;
                log.OprCompany = CurrentUserInfo.CompanyName;
                log.OprCityId = CurrentUserInfo.CityId;
                log.OprCity = CurrentUserInfo.CityName;
                log.SourceState = info.oldHouseStatus;
                log.TargetState = model.HouseStatus;
                log.OprType = "请求变更";
                Chenxin.Lib.House.DAL.ChangeLog.Add(log);
            }
            house_BaseInfo.UpdateTime = DateTime.Now;
            house_BaseInfo.ServiceTime = DateTime.Now;
            Chenxin.Lib.House.DAL.House_BaseInfo.Update(house_BaseInfo);
            
            //写房源更改记录
            house_BaseInfo_BakCol.CompanyId=CurrentUserInfo.CompanyId;
            house_BaseInfo_BakCol.CompanyName=CurrentUserInfo.CompanyName;
            house_BaseInfo_BakCol.Operator=CurrentUserInfo.UserName;
            house_BaseInfo_BakCol.OperatorId=CurrentUserInfo.UserId;
            house_BaseInfo_BakCol.Adddate=DateTime.Now;
            Chenxin.Lib.House.DAL.House_BaseInfo_BakCol.Add(house_BaseInfo_BakCol);
            //写客源更改记录
            //if (model.ChangeType == 30 || model.ChangeType == 20)
            //{
            //    customer_BaseInfo_BakCol.CompanyId = CurrentUserInfo.CompanyId;
            //    customer_BaseInfo_BakCol.CompanyName = CurrentUserInfo.CompanyName;
            //    customer_BaseInfo_BakCol.Operator = CurrentUserInfo.UserName;
            //    customer_BaseInfo_BakCol.OperatorId = CurrentUserInfo.UserId;
            //    customer_BaseInfo_BakCol.Adddate = DateTime.Now;
            //    Chenxin.Lib.House.DAL.Customer_BaseInfo_BakCol.Add(customer_BaseInfo_BakCol);
            //}
            //清除缓存
            string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_HOUSEINFO, house_BaseInfo.HouseId);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            cs.Delete(strCachKey);

            //添加跟单记录
            Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo = new Chenxin.Lib.House.Entity.House_TraceInfo();

            //跟单方式
            house_TraceInfo.TraceType = 0;
            //跟单内容	 
            if (model.ChangeType == 10)
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "通过了" + info.Operator + "将" + GetString(info.oldHouseStatus) + "变为" + GetString(info.HouseStatus) + "的请求！" + "   备注： " + info.ResonRemarks;
            }
            else if (model.ChangeType == 20)
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "通过了" + info.Operator + "将" + info.oldUserName + "变为" + info.RequestUser + "的请求！" + "   备注： " + info.ResonRemarks;
            }
            else
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "通过了" + info.Operator + "将" + GetString(info.oldHouseStatus) + "变为" + GetString(info.HouseStatus) + "," + info.oldUserName + "变为" + info.RequestUser + "的请求！" + "   备注： " + info.ResonRemarks;
            }
            //房源Id	 
            house_TraceInfo.HouseId = model.HouseId;
            //房源编号	
            house_TraceInfo.HouseCode = model.HouseCode;
            //房源地址	 
            house_TraceInfo.HouseAddress = house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room;
            house_TraceInfo.status = 0;

            house_TraceInfo.OprDepart = house_BaseInfo.OprDepart;
            house_TraceInfo.OprDepartId = house_BaseInfo.OprDepartId;
            house_TraceInfo.OprPerson = house_BaseInfo.OprPerson;
            house_TraceInfo.OprPersonId = house_BaseInfo.OprPersonId;
            AddTrace(house_TraceInfo);
            
            //添加用户操作日志 2010-5-12 王玮 Add
            AddLog("" + CurrentUserInfo.UserName + "确认通过请求变更了一个房源:[" + house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room + "]房源已通过请求变更。",
                    OperationType.OperationTypeComboList()["OprType_ChangeConfirmation"].ToString());
            
            return string.Format("{{success:'1',msg:'{0}',data:''}}", "确认请求成功！");
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }

    }

    //*******************************************
    //功能概要       ：拒绝请求
    //参数説明       ：houseid 房源主键 requestStyle 请求方式 RequestChangeStyle状态变更 personId 所属人变更 txtSummary 请求说明
    //返回值説明     ：void
    //功能詳細       ：确认请求
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string refuse(HttpContext context)
    {
        try
        {
            //转换成实体
            Chenxin.Lib.House.Entity.House_RequestChangeInfo model = (Chenxin.Lib.House.Entity.House_RequestChangeInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.House.Entity.House_RequestChangeInfo));
            if (model.RecordId == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求标识丢失，请联系管理员！");
            Chenxin.Lib.House.Entity.House_RequestChangeInfo info = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetModel(model.RecordId);
            if (info == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求信息丢失，请联系管理员！");
            }
            Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(info.HouseId);
            if (house_BaseInfo == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源信息丢失，请联系管理员！");
            }

            //更新记录
            /*info.Operator = CurrentUserInfo.UserName;
            info.OperatorId = CurrentUserInfo.UserId;
            info.OprDepart = CurrentUserInfo.DepartName;
            info.OprDepartId = CurrentUserInfo.DepartId;
            */
            info.DealTime = DateTime.Now;
            info.confirmPersonName = CurrentUserInfo.UserName;
            info.confirmPersonId = CurrentUserInfo.UserId;
            info.confirmDepartId = CurrentUserInfo.DepartId;
            info.confirmDepartName = CurrentUserInfo.DepartName;
            info.Status = 2;
            info.ResonRemarks = model.ResonRemarks;
            Chenxin.Lib.House.BLL.House_RequestChangeInfo.Update(info);

            //添加跟单记录
            Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo = new Chenxin.Lib.House.Entity.House_TraceInfo();
            //跟单方式
            house_TraceInfo.TraceType = 0;
            //跟单内容	 
            if (info.ChangeType == 10)
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "拒绝了" + info.Operator + "将" + GetString((int)info.oldHouseStatus) + "变为" + GetString((int)info.HouseStatus) + "的请求！" + "   备注： " + model.ResonRemarks;
            }
            else if (info.ChangeType == 20)
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "拒绝了" + info.Operator + "将" + info.oldUserName + "变为" + info.RequestUser + "的请求！" + "   备注： " + model.ResonRemarks;
            }
            else
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "拒绝了" + info.Operator + "将" + GetString((int)info.oldHouseStatus) + "变为" + GetString((int)info.HouseStatus) + "," + info.oldUserName + "变为" + info.RequestUser + "的请求！" + "   备注： " + model.ResonRemarks;
            }
            //房源Id	 
            house_TraceInfo.HouseId = model.HouseId;
            //房源编号	
            house_TraceInfo.HouseCode = model.HouseCode;
            //房源地址	 
            house_TraceInfo.HouseAddress = house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room;
            house_TraceInfo.status = 0;
            house_TraceInfo.OprDepart = house_BaseInfo.OprDepart;
            house_TraceInfo.OprDepartId = house_BaseInfo.OprDepartId;
            house_TraceInfo.OprPerson = house_BaseInfo.OprPerson;
            house_TraceInfo.OprPersonId = house_BaseInfo.OprPersonId;
            AddTrace(house_TraceInfo);
            
            //添加用户操作日志 2010-5-12 王玮 Add
            AddLog("" + CurrentUserInfo.UserName + "拒绝请求变更了一个房源:[" + house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room + "]房源已拒绝请求变更。",
                    OperationType.OperationTypeComboList()["OprType_ChangeConfirmation"].ToString());
            
            return string.Format("{{success:'1',msg:'{0}',data:''}}", "拒绝请求成功！");
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }

    //*******************************************
    //功能概要       ：添加请求
    //参数説明       ：houseid 房源主键 requestStyle 请求方式 RequestChangeStyle状态变更 personId 所属人变更 txtSummary 请求说明
    //返回值説明     ：void
    //功能詳細       ：添加请求
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string insert(HttpContext context)
    {
        try
        {
            //添加变更请求 
            //转换成实体
            Chenxin.Lib.House.Entity.House_RequestChangeInfo model = (Chenxin.Lib.House.Entity.House_RequestChangeInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.House.Entity.House_RequestChangeInfo));
            if (model.HouseId == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源标识丢失，请联系管理员！");
            Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(model.HouseId);
            if (model.ChangeType == 10)
            {
                if (house_BaseInfo.OprPersonId.Equals(CurrentUserInfo.UserId)) {
                    return string.Format("{{success:'0',msg:'{0}',data:''}}", "无法进行此操作，请至房源编辑处编辑房源记录！");
                }
                if (model.HouseStatus.Equals(house_BaseInfo.Status))
                {
                    return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求数据与当前数据一致！");
                }

            }
            else if (model.ChangeType == 20)
            {
                Chenxin.Lib.Passport.Entity.Hr_UserInfo user = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(model.RequestUserCode);

                if (house_BaseInfo.OprPersonId.Equals(user.UserId))
                {
                    return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求数据与当前数据一致！");
                }
                model.RequestUserCity = user.CityId;
                model.RequestUserCityName = user.CityName;
            }
            else if (model.ChangeType == 30)
            {
                Chenxin.Lib.Passport.Entity.Hr_UserInfo user = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(model.RequestUserCode);
                if (house_BaseInfo.OprPersonId.Equals(user.UserId) && model.HouseStatus.Equals(house_BaseInfo.Status))
                {
                    return string.Format("{{success:'0',msg:'{0}',data:''}}", "请求数据与当前数据一致！");
                }
                model.RequestUserCity = user.CityId;
                model.RequestUserCityName = user.CityName;
            }
            if (house_BaseInfo == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源信息丢失，请联系管理员！");
            if (house_BaseInfo.RequestNum == null)
                house_BaseInfo.RequestNum = 1;
            else
                house_BaseInfo.RequestNum = house_BaseInfo.RequestNum + 1;
            house_BaseInfo.IsNeedTran = true;
            Chenxin.Lib.House.DAL.House_BaseInfo.Update(house_BaseInfo);

            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_HOUSEINFO, house_BaseInfo.HouseId);
            cs.Delete(strCachKey);

            //向申请变更表中添加记录
            model.HouseAddress = house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room;
            model.RecordId = Guid.NewGuid();
            model.OperatorId = CurrentUserInfo.UserId;
            model.Operator = CurrentUserInfo.UserName;
            model.OprDepart = CurrentUserInfo.DepartName;
            model.OprDepartId = CurrentUserInfo.DepartId;
            model.CompanyId = CurrentUserInfo.CompanyId;
            model.CompanyName = CurrentUserInfo.CompanyName;
            model.OprCityId = CurrentUserInfo.CityId;
            model.OprCityName = CurrentUserInfo.CityName;
            model.Remarks = model.Remarks.Replace("\r", "\\r");
            model.Status = 0;
            model.Addtime = DateTime.Now;

            model.oldHouseStatus = house_BaseInfo.Status;
            model.oldCity = house_BaseInfo.CityId;
            model.oldCompanyId = house_BaseInfo.CompanyId;
            model.oldCompanyName = house_BaseInfo.CompanyName;
            model.oldDepart = house_BaseInfo.OprDepart;
            model.oldDepartId = house_BaseInfo.OprDepartId;
            model.oldUserId = house_BaseInfo.OprPersonId;
            model.oldUserName = house_BaseInfo.OprPerson;
            
            Chenxin.Lib.House.BLL.House_RequestChangeInfo.Add(model);

            //添加跟单记录
            Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo = new Chenxin.Lib.House.Entity.House_TraceInfo();
            //跟单方式
            house_TraceInfo.TraceType = 0;
            //跟单内容	 
            System.Text.StringBuilder sub = new System.Text.StringBuilder();
            sub.Append("请求将[" + model.HouseAddress+"]");
            if (model.ChangeType == 10)
            {
                sub.Append("的状态由" + GetString((int)house_BaseInfo.Status) + "变为" + GetString((int)model.HouseStatus));
            }
            else if (model.ChangeType == 20)
            {
                sub.Append("的所属人由" + house_BaseInfo.OprPerson + "变为" + model.RequestUser.ToString());
                sub.AppendFormat("  新业主 姓名：{0}",model.CustomerName, "-");
            }
            else
            {
                sub.Append("的状态由" + GetString((int)house_BaseInfo.Status) + "变为" + GetString((int)model.HouseStatus));
                sub.Append("，所属人由" + house_BaseInfo.OprPerson + "变为" + model.RequestUser.ToString());
                sub.AppendFormat("  新业主 姓名：{0}",model.CustomerName, "-");
            }
            sub.AppendFormat("   请求说明内容： {0}", model.Remarks);
            house_TraceInfo.TraceContext = sub.ToString();
            //房源Id	 
            house_TraceInfo.HouseId = model.HouseId;
            //房源编号	
            house_TraceInfo.HouseCode = model.HouseCode;
            //房源地址	 
            house_TraceInfo.HouseAddress = house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room;
            house_TraceInfo.status = 0;
            house_TraceInfo.OprDepart = house_BaseInfo.OprDepart;
            house_TraceInfo.OprDepartId = house_BaseInfo.OprDepartId;
            house_TraceInfo.OprPerson = house_BaseInfo.OprPerson;
            house_TraceInfo.OprPersonId = house_BaseInfo.OprPersonId;
            AddTrace(house_TraceInfo);
            
            //添加用户操作日志 2010-5-11 王玮 Add
            AddLog("" + CurrentUserInfo.UserName + "申请请求变更了一个房源:[" + house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room + "]房源已申请请求变更。",
                    OperationType.OperationTypeComboList()["OprType_ChangeConfirmation"].ToString());

            return string.Format("{{success:'1',msg:'{0}',data:''}}", "请求成功！");
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }



    //*******************************************
    //功能概要       ：房源变更
    //参数説明       ：houseid 房源主键 requestStyle 请求方式 RequestChangeStyle状态变更 personId 所属人变更 txtSummary 请求说明
    //返回值説明     ：void
    //功能詳細       ：添加请求
    //作成者         ：chenjie
    //作成日         ：2010-04-21
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string EditHouseStatus(HttpContext context)
    {
        try
        {
            //转换成实体
            Chenxin.Lib.House.Entity.House_RequestChangeInfo model = (Chenxin.Lib.House.Entity.House_RequestChangeInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.House.Entity.House_RequestChangeInfo));
           
            Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel(model.HouseId);
            if (house_BaseInfo == null)
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "房源信息丢失，请联系管理员！");
            Chenxin.Lib.House.Entity.Customer_BaseInfo customer_BaseInfo = Chenxin.Lib.House.DAL.Customer_BaseInfo.GetModel(house_BaseInfo.CustomerId);
            if (customer_BaseInfo == null)
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "用户信息丢失，请联系管理员！");
            }
            
            Chenxin.Lib.House.Entity.House_BaseInfo_BakCol house_BaseInfo_BakCol = new Chenxin.Lib.House.Entity.House_BaseInfo_BakCol();
            house_BaseInfo_BakCol.RecordId = Guid.NewGuid();
            house_BaseInfo_BakCol.HouseId = house_BaseInfo.HouseId;
            Chenxin.Lib.House.Entity.Customer_BaseInfo_BakCol customer_BaseInfo_BakCol = new Chenxin.Lib.House.Entity.Customer_BaseInfo_BakCol();
            customer_BaseInfo_BakCol.RecordId = Guid.NewGuid();
            customer_BaseInfo_BakCol.CustomerId = customer_BaseInfo.CustomerId;
            //添加跟单记录
            Chenxin.Lib.House.Entity.House_TraceInfo house_TraceInfo = new Chenxin.Lib.House.Entity.House_TraceInfo();
            
            if (model.ChangeType == 10)
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "变更了[" + house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room+"]的房源状态";
                house_BaseInfo_BakCol.ColumnName = "Status";
                house_BaseInfo_BakCol.ColumnDesc = "状态";
                house_BaseInfo_BakCol.OldValue = house_BaseInfo.Status.ToString();
                house_BaseInfo_BakCol.NewValue = model.HouseStatus.ToString();
                house_BaseInfo_BakCol.ChangeDesc = string.Format("状态由{0}改为：{1}", GetString(house_BaseInfo.Status), GetString(model.HouseStatus));
                house_BaseInfo.Status = Convert.ToInt32(model.HouseStatus);
            }
            else if (model.ChangeType == 20)
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "变更了[" + house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room + "]的房源所属人";
                house_BaseInfo_BakCol.ColumnName = "Person";
                house_BaseInfo_BakCol.ColumnDesc = "所属人";
                house_BaseInfo_BakCol.OldValue = "公司：" + house_BaseInfo.CompanyName + "部门：" + house_BaseInfo.OprDepart + "业务员：" + house_BaseInfo.OprPerson;
                Chenxin.Lib.Passport.Entity.Hr_UserInfo user = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(model.RequestUserCode);
                if (user != null)
                {
                    house_BaseInfo.CompanyName = user.CompanyName;
                    house_BaseInfo.CompanyId = user.CompanyId;
                    house_BaseInfo.CityId = user.CityId;
                    house_BaseInfo.OprDepart = user.DepartName;
                    house_BaseInfo.OprDepartId = user.DepartId;
                    house_BaseInfo.OprPerson = user.UserName;
                    house_BaseInfo.OprPersonId = user.UserId;

                    house_BaseInfo_BakCol.NewValue = "公司：" + house_BaseInfo.CompanyName + "部门：" + house_BaseInfo.OprDepart + "业务员：" + house_BaseInfo.OprPerson;
                    house_BaseInfo_BakCol.ChangeDesc = string.Format("房源所属由{0}改为：{1}", house_BaseInfo_BakCol.OldValue, house_BaseInfo_BakCol.NewValue);

                    //customer_BaseInfo_BakCol.ColumnName = "person,customer";
                    //customer_BaseInfo_BakCol.ColumnDesc = "所属人，客户信息";
                    //customer_BaseInfo_BakCol.OldValue = "公司：" + customer_BaseInfo.CompanyName + "部门：" + customer_BaseInfo.OprDepart + "业务员：" + customer_BaseInfo.OprPerson + "电话：" + customer_BaseInfo.Phone + "手机：" + customer_BaseInfo.Mobile + "客户姓名：" + customer_BaseInfo.CustomerName;

                    //新增客户日志方法 by  tianno  2011-1-13*********************
                    //判断客户姓名是否被修改
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.CustomerName, customer_BaseInfo.CustomerName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CustomerName", "客户姓名", customer_BaseInfo.CustomerName, model.CustomerName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //城市
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.CityName, customer_BaseInfo.CityName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CityName", "城市", customer_BaseInfo.CityName, user.CityName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //公司
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.CompanyName, customer_BaseInfo.CompanyName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CompanyName", "公司", customer_BaseInfo.CompanyName, user.CompanyName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //部门
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.DepartName, customer_BaseInfo.OprDepart))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprDepart", "部门", customer_BaseInfo.OprDepart, user.DepartName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //人员
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(user.UserName, customer_BaseInfo.OprPerson))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprPerson", "人员", customer_BaseInfo.OprPerson, user.UserName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //手机
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Mobile, customer_BaseInfo.Mobile))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Mobile", "手机号码", customer_BaseInfo.Mobile, model.Mobile, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //判断联系电话是否被修改
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Phone, customer_BaseInfo.Phone))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Phone", "联系电话", customer_BaseInfo.Phone, model.Phone, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    
                    //***********************************************************
                    customer_BaseInfo.CustomerName = model.CustomerName;
                    customer_BaseInfo.Mobile = model.Mobile;
                    customer_BaseInfo.Phone = model.Phone;
                    customer_BaseInfo.OprDepart = user.DepartName;
                    customer_BaseInfo.OprDepartId = user.DepartId;
                    customer_BaseInfo.OprPerson = user.UserName;
                    customer_BaseInfo.OprPersonId = user.UserId;
                    customer_BaseInfo.CityId = user.CityId;
                    customer_BaseInfo.CityName = user.CityName;
                    customer_BaseInfo.CompanyName = user.CompanyName;
                    customer_BaseInfo.CompanyId = user.CompanyId;
                    //customer_BaseInfo_BakCol.NewValue = "公司：" + customer_BaseInfo.CompanyName + "部门：" + customer_BaseInfo.OprDepart + "业务员：" + customer_BaseInfo.OprPerson + "电话：" + customer_BaseInfo.Phone + "手机：" + customer_BaseInfo.Mobile + "客户姓名：" + customer_BaseInfo.CustomerName;
                    //customer_BaseInfo_BakCol.ChangeDesc = string.Format("客户信息由{0}改为：{1}", customer_BaseInfo_BakCol.OldValue, customer_BaseInfo_BakCol.NewValue);
                }
                Chenxin.Lib.House.DAL.Customer_BaseInfo.Update(customer_BaseInfo);
            }
            else if (model.ChangeType == 30)
            {
                house_TraceInfo.TraceContext = CurrentUserInfo.UserName + "变更了[" + house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room + "]的房源状态和所属人";
                house_BaseInfo_BakCol.ColumnName = "Person,Status";
                house_BaseInfo_BakCol.ColumnDesc = "所属人,状态";
                house_BaseInfo_BakCol.OldValue = "公司：" + house_BaseInfo.CompanyName + "部门：" + house_BaseInfo.OprDepart + "业务员：" + house_BaseInfo.OprPerson + "状态：" + GetString(house_BaseInfo.Status);

                //customer_BaseInfo_BakCol.ColumnName = "person,customer";
                //customer_BaseInfo_BakCol.ColumnDesc = "所属人，客户信息";
                //customer_BaseInfo_BakCol.OldValue = "公司：" + customer_BaseInfo.CompanyName + "部门：" + customer_BaseInfo.OprDepart + "业务员：" + customer_BaseInfo.OprPerson + "电话：" + customer_BaseInfo.Phone + "手机：" + customer_BaseInfo.Mobile + "客户姓名：" + customer_BaseInfo.CustomerName;
                
                
                //新增客户日志方法 by  tianno  2011-1-13*********************
                //判断客户姓名是否被修改
                if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.CustomerName, customer_BaseInfo.CustomerName))
                {
                    Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CustomerName", "客户姓名", customer_BaseInfo.CustomerName, model.CustomerName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                }
                //手机
                if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Mobile, customer_BaseInfo.Mobile))
                {
                    Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Mobile", "手机号码", customer_BaseInfo.Mobile, model.Mobile, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                }
                //判断联系电话是否被修改
                if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(model.Phone, customer_BaseInfo.Phone))
                {
                    Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "Phone", "联系电话", customer_BaseInfo.Phone, model.Phone, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                }
                //***********************************************************
                
                customer_BaseInfo.CustomerName = model.CustomerName;
                customer_BaseInfo.Mobile = model.Mobile;
                customer_BaseInfo.Phone = model.Phone;
                Chenxin.Lib.Passport.Entity.Hr_UserInfo userinfo = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(model.RequestUserCode);
                if (userinfo != null)
                {
                    //新增客户日志方法 by  tianno  2011-1-13*********************                    
                    //城市
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.CityName, customer_BaseInfo.CityName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CityName", "城市", customer_BaseInfo.CityName, userinfo.CityName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //公司
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.CompanyName, customer_BaseInfo.CompanyName))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "CompanyName", "公司", customer_BaseInfo.CompanyName, userinfo.CompanyName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //部门
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.DepartName, customer_BaseInfo.OprDepart))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprDepart", "部门", customer_BaseInfo.OprDepart, userinfo.DepartName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //人员
                    if (!Chenxin.Lib.House.BLL.Custom_Info.strEqual(userinfo.UserName, customer_BaseInfo.OprPerson))
                    {
                        Chenxin.Lib.House.BLL.Custom_Info.AddCustomerInfoBakCol(customer_BaseInfo.CustomerId, CurrentUserInfo.UserId, CurrentUserInfo.UserName, "OprPerson", "人员", customer_BaseInfo.OprPerson, userinfo.UserName, CurrentUserInfo.CompanyId, CurrentUserInfo.CompanyName,0);
                    }
                    //***********************************************************
                    
                    
                    customer_BaseInfo.OprDepart = userinfo.DepartName;
                    customer_BaseInfo.OprDepartId = userinfo.DepartId;
                    customer_BaseInfo.OprPerson = userinfo.UserName;
                    customer_BaseInfo.OprPersonId = userinfo.UserId;
                    customer_BaseInfo.CityId = userinfo.CityId;
                    customer_BaseInfo.CityName = userinfo.CityName;
                    customer_BaseInfo.CompanyName = userinfo.CompanyName;
                    customer_BaseInfo.CompanyId = userinfo.CompanyId;

                    Chenxin.Lib.House.DAL.Customer_BaseInfo.Update(customer_BaseInfo);
                    house_BaseInfo.CompanyName = userinfo.CompanyName;
                    house_BaseInfo.CompanyId = userinfo.CompanyId;
                    house_BaseInfo.CityId = userinfo.CityId;
                    house_BaseInfo.OprDepart = userinfo.DepartName;
                    house_BaseInfo.OprDepartId = userinfo.DepartId;
                    house_BaseInfo.OprPerson = userinfo.UserName;
                    house_BaseInfo.OprPersonId = userinfo.UserId;
                    house_BaseInfo.Status = Convert.ToInt32(model.HouseStatus);
                    house_BaseInfo_BakCol.NewValue = "公司：" + house_BaseInfo.CompanyName + "部门：" + house_BaseInfo.OprDepart + "业务员：" + house_BaseInfo.OprPerson + "状态：" + GetString(house_BaseInfo.Status);
                    house_BaseInfo_BakCol.ChangeDesc = string.Format("房源所属由{0}改为：{1}", house_BaseInfo_BakCol.OldValue, house_BaseInfo_BakCol.NewValue);

                    //customer_BaseInfo_BakCol.NewValue = "公司：" + customer_BaseInfo.CompanyName + "部门：" + customer_BaseInfo.OprDepart + "业务员：" + customer_BaseInfo.OprPerson + "电话：" + customer_BaseInfo.Phone + "手机：" + customer_BaseInfo.Mobile + "客户姓名：" + customer_BaseInfo.CustomerName;
                    //customer_BaseInfo_BakCol.ChangeDesc = string.Format("客户信息由{0}改为：{1}", customer_BaseInfo_BakCol.OldValue, customer_BaseInfo_BakCol.NewValue);
                }
            }

            house_BaseInfo.UpdateTime = DateTime.Now;
            house_BaseInfo.ServiceTime = DateTime.Now;
            Chenxin.Lib.House.DAL.House_BaseInfo.Update(house_BaseInfo);

            //清除缓存
            string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_HOUSEINFO, house_BaseInfo.HouseId);
            Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            cs.Delete(strCachKey);

            house_BaseInfo.UpdateTime = DateTime.Now;
            house_BaseInfo.ServiceTime = DateTime.Now;
            Chenxin.Lib.House.DAL.House_BaseInfo.Update(house_BaseInfo);

            //写房源更改记录
            house_BaseInfo_BakCol.CompanyId = CurrentUserInfo.CompanyId;
            house_BaseInfo_BakCol.CompanyName = CurrentUserInfo.CompanyName;
            house_BaseInfo_BakCol.Operator = CurrentUserInfo.UserName;
            house_BaseInfo_BakCol.OperatorId = CurrentUserInfo.UserId;
            house_BaseInfo_BakCol.Adddate = DateTime.Now;
            Chenxin.Lib.House.DAL.House_BaseInfo_BakCol.Add(house_BaseInfo_BakCol);
            //if (model.ChangeType == 30 || model.ChangeType == 20)
            //{
            //    //写客源更改记录
            //    customer_BaseInfo_BakCol.CompanyId = CurrentUserInfo.CompanyId;
            //    customer_BaseInfo_BakCol.CompanyName = CurrentUserInfo.CompanyName;
            //    customer_BaseInfo_BakCol.Operator = CurrentUserInfo.UserName;
            //    customer_BaseInfo_BakCol.OperatorId = CurrentUserInfo.UserId;
            //    customer_BaseInfo_BakCol.Adddate = DateTime.Now;
            //    Chenxin.Lib.House.DAL.Customer_BaseInfo_BakCol.Add(customer_BaseInfo_BakCol);
            //}
            //清除缓存
            strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_HOUSEINFO, house_BaseInfo.HouseId);
            cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
            cs.Delete(strCachKey);

            //跟单方式
            house_TraceInfo.TraceType = 0;
            //房源Id	 
            house_TraceInfo.HouseId = model.HouseId;
            //房源编号	
            house_TraceInfo.HouseCode = model.HouseCode;
            //房源地址	 
            house_TraceInfo.HouseAddress = house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room;
            house_TraceInfo.status = 0;
            house_TraceInfo.OprDepart = house_BaseInfo.OprDepart;
            house_TraceInfo.OprDepartId = house_BaseInfo.OprDepartId;
            house_TraceInfo.OprPerson = house_BaseInfo.OprPerson;
            house_TraceInfo.OprPersonId = house_BaseInfo.OprPersonId;
            AddTrace(house_TraceInfo);
            //添加用户操作日志 2010-5-11 王玮 Add
            AddLog(CurrentUserInfo.UserName + "变更了[" + house_BaseInfo.Community + house_BaseInfo.BuildingName + house_BaseInfo.Room + "]房源。","房源变更");
            
            return string.Format("{{success:'1',msg:'{0}',data:''}}", "变更成功！");
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }



    //*******************************************
    //功能概要       ：验证工号
    //参数説明       ：personId 工号
    //返回值説明     ：void
    //功能詳細       ：验证工号
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string validate(HttpContext context)
    {
        try
        {
            string personId = context.Request["requestChangePersonId"];
            Chenxin.Lib.Passport.Entity.Hr_UserInfo userInfo = Chenxin.Lib.Passport.DAL.Hr_UserInfo.GetEntityByCode(personId);
            if (userInfo != null)
            {
                return string.Format("{{success:'1',msg:'成功',data:{{model:{0}}}}}", Chenxin.Lib.Utility.JsonHelp.Convert2Json(userInfo));
            }
            else
            {
                return string.Format("{{success:'0',msg:'{0}',data:''}}", "用户不存在！");
            }
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }

    //*******************************************
    //功能概要       ：获得请求列表
    //参数説明       ：请求列表
    //返回值説明     ：void
    //功能詳細       ：获得请求列表
    //作成者         ：chen.yugong 
    //作成日         ：2010-03-02
    //修改者         ：
    //修改日         ：
    //*******************************************
    private string search(HttpContext context)
    {
        try
        {
            int iPageIndex = (string.IsNullOrEmpty(context.Request["pageindex"])) ? 1 : int.Parse(context.Request["pageindex"]) + 1;//页码
            int iPageSize = (string.IsNullOrEmpty(context.Request["pagesize"])) ? 30 : int.Parse(context.Request["pagesize"]);//页记录数

            string fieldlist = "confirmPersonName,DealTime,RecordId,CustomerName, Mobile, Phone,flg,RequestUser,RequestDepart,ChangeType,Remarks,HouseAddress,Status,flg1,HouseId,HouseStatus,Operator,Addtime,oldUserName,oldHouseStatus";
            string fieldtablelist = "confirmPersonName,DealTime,RecordId,CustomerName, Mobile, Phone,Status as flg,RequestUser,RequestDepart,CASE ChangeType when '10'  then '变更状态' when '20' then '变更所属人' when '30' then '两者都变更' end as ChangeType,Remarks,HouseAddress,CASE Status when '0'  then '未处理' when '1' then '已通过' when '2' then '已否决' end as Status,ChangeType as flg1,HouseId,HouseStatus,Operator,Addtime,oldUserName,oldHouseStatus";
            string orderfield = " House_RequestChangeInfo.Status,House_RequestChangeInfo.HouseCode, House_RequestChangeInfo.Addtime";

            Guid city = (string.IsNullOrEmpty(context.Request["cityid"])) ? Guid.Empty : new Guid(context.Request["cityid"]);
            Guid company = (string.IsNullOrEmpty(context.Request["companyid"])) ? Guid.Empty : new Guid(context.Request["companyid"]);
            Guid businessdistrict = (string.IsNullOrEmpty(context.Request["areaid"])) ? Guid.Empty : new Guid(context.Request["areaid"]);
            Guid departs = (string.IsNullOrEmpty(context.Request["departid"])) ? Guid.Empty : new Guid(context.Request["departid"]);
            Guid employee = (string.IsNullOrEmpty(context.Request["userid"])) ? Guid.Empty : new Guid(context.Request["userid"]);

            //判断权限范围/////////////////////////////////////////////
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (employee != Guid.Empty)
                sb.AppendFormat(" AND (House_RequestChangeInfo.OperatorId = '{0}' or House_RequestChangeInfo.RequestUserId = '{0}') ", employee);
            else if (departs != Guid.Empty)
                sb.AppendFormat(" AND (House_RequestChangeInfo.OprDepartId = '{0}' or House_RequestChangeInfo.RequestDepartId = '{0}')", departs);
            else if (businessdistrict != Guid.Empty)
            {
                Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo item = null;
                string strCachkey = string.Format(Chenxin.Lib.Cache.CacheDataType.GLOBAL_DEPARTMENT, businessdistrict);
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.GLOBAL);
                item = cs.GetObject<Chenxin.Lib.Hr.Entity.Hr_DepartmentInfo>(strCachkey);
                if (!cs.Hit)
                {
                    item = Chenxin.Lib.Hr.DAL.Hr_DepartmentInfo.GetModel(businessdistrict);
                    if (item != null) cs.Set(strCachkey, item, DateTime.Now.AddDays(1));
                }

                if (item == null) return string.Format("{{success:'0',msg:'{0}',data:''}}", "获取商圈或分类数据丢失");

                sb.AppendFormat(" AND (House_RequestChangeInfo.OprDepartId in (select departId from v_Hr_DepartmentInfo where DepartSrc like '{0}%') or House_RequestChangeInfo.RequestDepartId in (select departId from v_Hr_DepartmentInfo where DepartSrc like '{0}%'))", item.DepartSrc);
            }
            else if (company != Guid.Empty)
                sb.AppendFormat(" AND (House_RequestChangeInfo.CompanyId = '{0}')", company);
            else if (city != Guid.Empty)
                sb.AppendFormat(" AND (House_RequestChangeInfo.OprCityId ='{0}')", city);
            else
                sb.AppendFormat(" AND (House_RequestChangeInfo.CompanyId = '{0}')", CurrentUserInfo.CompanyId);
            
            System.Text.StringBuilder sb1 = new System.Text.StringBuilder();

            string flg = context.Request["appflg"];

            if (("appfordepart").Equals(flg))
            {
                //查看所有请求权限
                if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_All))
                {
                    sb1.Append(" (1=1) ");
                }
                //查看城市请求权限
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_City))
                {
                    sb1.AppendFormat(" (House_RequestChangeInfo.OprCityId = '{0}') ", CurrentUserInfo.CityId);
                    /*
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Hr_User_BaseInfo M ");
                    sb1.AppendFormat("WHERE House_RequestChangeInfo.oldUserId = M.Userid AND  M.CityId= '{0}' ", CurrentUserInfo.CityId);
                     */
                }
                //查看公司请求权限
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_Company))
                {
                    sb1.AppendFormat(" (House_RequestChangeInfo.CompanyId = '{0}') ", CurrentUserInfo.CompanyId);
                    /*
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Hr_User_BaseInfo M ");
                    sb1.AppendFormat("WHERE House_RequestChangeInfo.oldUserId = M.Userid AND  M.CompanyId= '{0}' ", CurrentUserInfo.CompanyId);
                    sb1.Append(")");
                     */
                }
                //查看部门请求权限
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_Department))
                {
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Struct_UserDepartRelation M ");
                    sb1.AppendFormat("WHERE (House_RequestChangeInfo.oldDepartId = M.Departid AND  M.Userid= '{0}') ", CurrentUserInfo.UserId);
                    sb1.Append(")");
                }
                else
                {
                    sb1.AppendFormat(" House_RequestChangeInfo.oldUserId = '{0}'", CurrentUserInfo.UserId);
                }
            }
            else {
                //查看所有请求权限
                if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_All))
                {
                    sb1.Append(" (1=1) ");
                }
                //查看城市请求权限
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_City))
                {
                    sb1.AppendFormat(" (House_RequestChangeInfo.OprCityId = '{0}') ", CurrentUserInfo.CityId);
                    /*
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Hr_User_BaseInfo M ");
                    sb1.AppendFormat("WHERE (House_RequestChangeInfo.RequestUserId = M.Userid OR House_RequestChangeInfo.OperatorId = M.Userid) AND  M.CityId= '{0}' ", CurrentUserInfo.CityId);
                    sb1.Append(")");
                     */
                }
                //查看公司请求权限
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_Company))
                {
                    sb1.AppendFormat(" (House_RequestChangeInfo.CompanyId = '{0}') ", CurrentUserInfo.CompanyId);
                    /*
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Hr_User_BaseInfo M ");
                    sb1.AppendFormat("WHERE (House_RequestChangeInfo.RequestUserId = M.Userid  OR House_RequestChangeInfo.OperatorId = M.Userid)  AND  M.CompanyId= '{0}' ", CurrentUserInfo.CompanyId);
                    sb1.Append(")");
                     */
                }
                //查看部门请求权限
                else if (CurrentUserInfo.ContainsPermit(Constants.Permit_RequestView_Department))
                {
                    sb1.Append("EXISTS(");
                    sb1.Append("Select 1 from v_Struct_UserDepartRelation M ");
                    sb1.AppendFormat("WHERE ((House_RequestChangeInfo.RequestDepartId = M.Departid OR House_RequestChangeInfo.OprDepartId = M.Departid) AND  M.Userid= '{0}' and M.ViewChange = 1) ", CurrentUserInfo.UserId);
                    sb1.Append(")");
                }
                else
                {
                    sb1.AppendFormat(" (House_RequestChangeInfo.RequestUserId = '{0}' OR House_RequestChangeInfo.OperatorId = '{1}') ", CurrentUserInfo.UserId, CurrentUserInfo.UserId);
                }
            }
         
            if (!String.IsNullOrEmpty(sb.ToString()))
                sb1.Append(sb.ToString());
            
            
            string stime = context.Request.QueryString["stime"];
            string etime = context.Request.QueryString["etime"];
            string strquery = context.Request.QueryString["strquery"];
            string requeststatus = context.Request.QueryString["requeststatus"];
            if (!String.IsNullOrEmpty(stime))
            {
                sb1.Append(string.Format(" AND convert(varchar(10),(convert(datetime,House_RequestChangeInfo.Addtime,120)),120)  >= '{0}'", (stime)));
            }
            if (!String.IsNullOrEmpty(etime))
            {
                sb1.Append(string.Format(" AND convert(varchar(10),(convert(datetime,House_RequestChangeInfo.Addtime,120)),120)  <= '{0}'", (etime)));
            }
            if (!String.IsNullOrEmpty(strquery))
            {
                sb1.AppendFormat("AND (House_RequestChangeInfo.HouseAddress LIKE '%{0}%' OR House_RequestChangeInfo.HouseCode like '%{0}%')", strquery);
            }
            if (!String.IsNullOrEmpty(requeststatus))
            {
                if ("3".Equals(requeststatus)) {
                    sb1.Append(string.Format(" and (House_RequestChangeInfo.Status= '{0}' or House_RequestChangeInfo.Status= '{1}')", 1, 2));
                }
                else
                {
                    sb1.Append(string.Format(" and House_RequestChangeInfo.Status= '{0}'", requeststatus));
                }
            }
            //判断权限范围结束////////////////////////////////////////////

            System.Data.DataSet list = null;
            list = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetList(
                iPageIndex, iPageSize, orderfield, "House_RequestChangeInfo", sb1.ToString(), fieldlist, fieldtablelist, true);
            int count = (int)list.Tables[1].Rows[0][0];
            string strHtml = "";
            System.Text.StringBuilder sbhtml = new System.Text.StringBuilder();

            sbhtml.Append("<table width=\"100%\" height=\"100%\" cellspacing=\"1\" class=\"tabsorternew\" id=\"report\">");
            sbhtml.Append("<thead><tr>");
            sbhtml.Append("<th width=\"25\">操作</th>");
            sbhtml.Append("<th width=\"60\"> 请求人/房源所属人</th>");
            sbhtml.Append("<th width=\"165\">变更内容</th>");
            sbhtml.Append("<th width=\"30\" >变更类型</th>");
            sbhtml.Append("<th width=\"25\">处理状态</th>");
            sbhtml.Append("<th width=\"55\">请求/处理时间</th>");
            sbhtml.Append("</tr></thead><tbody>");
            int i = 0;
            foreach (System.Data.DataRow row in list.Tables[0].Rows)
            {
                int status = -100;
                if (!string.IsNullOrEmpty(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "flg", "")))
                {
                    status = Convert.ToInt32(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "flg", ""));
                }
                string button = string.Empty;
                if (0 == status)
                {
                    button = string.Format("<a name=\"{0}\" href=\"javascript:void(0)\" class=\"a_auditing\">审核</a>|<a name=\"{0}\" href=\"javascript:void(0)\" class=\"a_auditing_detail\">查看</a><br/><a name=\"{1}\" href=\"javascript:void(0)\" class=\"a_viewowner\">查看业主</a>", row["RecordId"], row["RecordId"]);
                }
                else
                {
                    button = string.Format("<a name=\"{0}\" href=\"javascript:void(0)\" class=\"a_auditing_detail\">审核</a>|<a name=\"{0}\" href=\"javascript:void(0)\" class=\"a_auditing_detail\">查看</a><br/><a name=\"{1}\" href=\"javascript:void(0)\" class=\"a_viewowner\">查看业主</a>", row["RecordId"], row["RecordId"]);
                }
                if (i%2 == 0)
                    sbhtml.AppendFormat("<tr id=\"{0}\" class=\"tr_houselist\">", row["RecordId"].ToString());
                else
                    sbhtml.AppendFormat("<tr id=\"{0}\" class=\"tr_houselist bluebgcolor\">", row["RecordId"].ToString());

                sbhtml.AppendFormat("<td>{0}</td>", button);
                string user = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Operator", "") + "/" + Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "oldUserName", "");
                 string prcePer =  Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "confirmPersonName", "");
                if(!string.IsNullOrEmpty(prcePer)) 
                {
                    user = user + "<br/>处理人： " + prcePer;
                }
                sbhtml.AppendFormat("<td>{0}</td>", user);
                
                System.Text.StringBuilder sub = new System.Text.StringBuilder();
                //sub.Append(Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Operator", "") + "请求将<span style=\"color:blue; font-weight:bold;\">[" + Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "HouseAddress", "") + "]</span>处房源");
                sub.AppendFormat("请求将 <a href=\"ShowDetailInfo.aspx?houseid={0}\" target=\"blank\">{1}</a> ", row["HouseId"], Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "HouseAddress", ""));
                int sts = Convert.ToInt32(row["flg1"]);

                Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel((Guid)row["HouseId"]);
                if (house_BaseInfo == null)
                    return string.Format("{{success:'0',msg:'{0}',data:''}}", row["HouseAddress"] + "对应房源标识丢失，请联系管理员！");
                if (sts == 10)
                {
                    sub.Append("的状态由<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["oldHouseStatus"]) + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["HouseStatus"]) + "</span>");
                }
                else if (sts == 20)
                {
                    sub.Append("的所属人由<span style=\"color:blue; font-weight:bold;\">" + row["oldUserName"] + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + row["RequestUser"].ToString() + "</span>");
                    sub.AppendFormat("<br/>新业主 姓名：{0} 电话：{1}",
                        Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CustomerName", "-").Replace("'", "\\'"),
                        Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Mobile", "-") +"/" + Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Phone", "-")
                        );
                }
                else
                {
                    sub.Append("的状态由<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["oldHouseStatus"]) + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["HouseStatus"]));
                    sub.Append("</span>，所属人由<span style=\"color:blue; font-weight:bold;\">" + row["oldUserName"] + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + row["RequestUser"].ToString() + "</span>");
                    sub.AppendFormat("<br/>新业主 姓名：{0} 电话：{1}",
                        Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "CustomerName", "-"),
                        Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Mobile", "-") + "/" + Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Phone", "-")
                        );
                }

                sbhtml.AppendFormat("<td>{0}</td>", sub.ToString());
                //sbhtml.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "HouseAddress", ""));
                sbhtml.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ChangeType", ""));
                sbhtml.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Status", ""));
                string time = Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Addtime", "")+"<br/>"+ Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DealTime", "-");
                sbhtml.AppendFormat("<td>{0}</td>", time);
                sbhtml.Append("</tr>");
                
                i++;
            }
            sbhtml.Append("</tbody></table>");
            strHtml = sbhtml.ToString();


            list.Dispose();
            list = null;
            return string.Format("{{success:'1',msg:'{0}',data:{{count:'{1}',data:'{2}'}}}}", "成功", count, strHtml);
        }
        catch (Exception ex)
        {
            return string.Format("{{success:'0',msg:'意外错误：{0}',data:''}}", ex.Message);
        }
    }

    private string GetString(int? status)
    {
        string str = string.Empty;
        if (status == 10)
        {
            str = "有效";
        }
        else if (status == -1)
        {
            str = "无效";
        }
        else
        {
            str = "暂缓";
        }
        return str;
    }

    //返回值説明     ：响应字符串
    //功能詳細       ：某一房屋对应任务信息
    //作成者         ：chenyg
    //作成日         ：2010-07-07
    //修改者         ：
    //修改日         ：
    //*******************************************
    private void getHouseRequestList(HttpContext context)
    {
        string strRet;
        try
        {
            string houseid = context.Request.Params["houseid"];
            int PageIndex = 1;
            int PageSize = 10;

            //页码        
            if (!string.IsNullOrEmpty(context.Request.Params["pageindex"]))
            {
                PageIndex = int.Parse(context.Request.Params["pageindex"]) + 1;
            }
            //页显示行数
            if (!string.IsNullOrEmpty(context.Request.Params["pagesize"]))
            {
                PageSize = int.Parse(context.Request.Params["pagesize"]);
            }

            string orderfield = "House_RequestChangeInfo.Addtime desc";
            string StrWhere = "HouseId='" + houseid + "'";
            string FieldList = "RecordId,CustomerName, Mobile, Phone,flg,RequestUser,RequestDepart,ChangeType,Remarks,HouseAddress,Status,flg1,HouseId,HouseStatus,Operator,Addtime,oldUserName,oldHouseStatus,confirmDepartName,OprDepart,DealTime,confirmPersonName";
            string TableFieldList = "RecordId,CustomerName, Mobile, Phone,Status as flg,RequestUser,RequestDepart,CASE ChangeType when '10'  then '变更状态' when '20' then '变更所属人' when '30' then '两者都变更' end as ChangeType,Remarks,HouseAddress,CASE Status when '0'  then '处理中' when '1' then '处理完成' when '2' then '请求被否决' end as Status,ChangeType as flg1,HouseId,HouseStatus,Operator,Addtime,oldUserName,oldHouseStatus,confirmDepartName,OprDepart,DealTime,confirmPersonName";
            string TableName = "House_RequestChangeInfo";

            //根据sql执行查询
            DataSet ds = null;
            if (PageIndex == 1)
            {
                Chenxin.Lib.Cache.CacheService cs = new Chenxin.Lib.Cache.CacheService(Chenxin.Lib.Cache.CacheConn.xCacheConn.HOUSE);
                string strCachKey = string.Format(Chenxin.Lib.Cache.CacheDataType.HOUSE_INFO_REQUEST, houseid);
                ds = cs.GetDataSet(strCachKey);
                if (!cs.Hit)
                {
                    ds = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetList(PageIndex,PageSize, orderfield, TableName, StrWhere, FieldList, TableFieldList, true);
                    if (ds != null)
                        cs.Set(strCachKey, ds, DateTime.Now.AddMinutes(5));
                }
            }
            else
            {
                ds = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetList(PageSize, PageIndex, orderfield, TableName, StrWhere, FieldList, TableFieldList, true);
            }

            strRet = retExecResult(Constants.ExecResult.Succ, "", retPagination(ds));
            context.Response.Write(strRet);
        }
        catch (Exception ex)
        {
            strRet = retExecResult(Constants.ExecResult.Error, ex.Message, "");
            context.Response.Write(strRet);
        }
    }

    //生成html
    private Constants.Pagination retPagination(DataSet ds)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        //请求类型，请求内容，请求人，请求部门，请求时间，处理状态，处理人，处理部门，处理时间。
        sb.Append("<table id=\"request\" width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\"><thead>");
        sb.Append("<tr class=\"tab_line4\">");
        sb.Append("<td width=\"45px\"><b>请求类型</b></td>");
        sb.Append("<td width=\"100px\"><b>请求内容</b></td>");
        sb.Append("<td width=\"40px\"><b>请求人</b></td>");
        sb.Append("<td width=\"40px\"><b>请求部门</b></td>");
        sb.Append("<td width=\"35px\"><b>请求时间</b></td>");
        sb.Append("<td width=\"40px\"><b>处理状态</b></td>");
        sb.Append("<td width=\"30px\"><b>处理人</b></td>");
        sb.Append("<td width=\"40px\"><b>处理部门</b></td>");
        sb.Append("<td width=\"35px\"><b>处理时间</b></td>");
        sb.Append("</tr>");
        foreach (System.Data.DataRow row in ds.Tables[0].Rows)
        {
            Chenxin.Lib.House.Entity.House_BaseInfo house_BaseInfo = Chenxin.Lib.House.DAL.House_BaseInfo.GetModel((Guid)row["HouseId"]);
            System.Text.StringBuilder sub = new System.Text.StringBuilder();
            sub.AppendFormat("请求将 <a href=\"ShowDetailInfo.aspx?houseid={0}\" target=\"blank\">{1}</a> ", row["HouseId"], Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "HouseAddress", ""));
            int sts = Convert.ToInt32(row["flg1"]);
            if (sts == 10)
            {
                sub.Append("的状态由<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["oldHouseStatus"]) + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["HouseStatus"]) + "</span>");
            }
            else if (sts == 20)
            {
                sub.Append("的所属人由<span style=\"color:blue; font-weight:bold;\">" + row["oldUserName"] + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + row["RequestUser"].ToString() + "</span>");
            }
            else
            {
                sub.Append("的状态由<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["oldHouseStatus"]) + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + GetString((int)row["HouseStatus"]));
                sub.Append("</span>，所属人由<span style=\"color:blue; font-weight:bold;\">" + row["oldUserName"] + "</span>变为<span style=\"color:blue; font-weight:bold;\">" + row["RequestUser"].ToString() + "</span>");
            }
            sb.AppendFormat("<tr class=\"tab_line5\">");
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "ChangeType", ""));
            sb.AppendFormat("<td>{0}</td>", sub.ToString());
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Operator", ""));
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "OprDepart", ""));
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Addtime", ""));
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "Status", ""));
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "confirmPersonName", "-"));
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "confirmDepartName", "-"));
            sb.AppendFormat("<td>{0}</td>", Chenxin.Lib.Utility.DatasetHelper.GetValue(row, "DealTime", "-"));
            sb.Append("</tr>");
        }
        sb.Append("</thead></table>");

        Constants.Pagination stuPag = new Constants.Pagination();
        stuPag.count = Convert.ToInt32(ds.Tables[1].Rows[0][0]);
        stuPag.data = sb.ToString();

        return stuPag;
    }
    //*******************************************
    //功能概要       ：响应字符串
    //参数説明       ：strMsg 消息 
    //返回值説明     ：void
    //功能詳細       ：权限检查
    //作成者         ：chen.yugong 
    //作成日         ：2010-05-20
    //修改者         ：
    //修改日         ：
    //*******************************************
    public override bool CustomerCheckPermint(HttpContext context, out string strMsg)
    {
        if (context.Request["op"] != null)
        {
            string op = context.Request["op"].ToLower();
            //实体变量
            Chenxin.Lib.House.Entity.House_RequestChangeInfo model = null;
            //传递参数用
            System.Collections.Hashtable per = new System.Collections.Hashtable();
            System.Collections.Hashtable confine = new System.Collections.Hashtable();
            //判断op参数
            if (op.Equals("confirm"))
            {
                //转换成实体
                model = (Chenxin.Lib.House.Entity.House_RequestChangeInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.House.Entity.House_RequestChangeInfo));
                if (model.RecordId == null)
                {
                    strMsg = "{success:0,msg:'获取请求数据失败！',data:''}";
                    return false;
                }
                model = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetModel(model.RecordId);
                if (model == null)
                {
                    strMsg = "{success:0,msg:'获取请求数据失败！',data:''}";
                    return false;
                }
                //加如权限项
                per.Add("ALL", Constants.Permit_ComfrimRequest_All);
                per.Add("CITY", Constants.Permit_ComfrimRequest_City);
                per.Add("COMPANY", Constants.Permit_ComfrimRequest_Company);
                per.Add("DEPART", Constants.Permit_ComfrimRequest_Department);
                //加入范围
                confine.Add("CityId", model.oldCity);
                confine.Add("CompanyId", model.oldCompanyId);
                confine.Add("OperatorId", model.oldUserId);
                //检查权限
                return CheckPermint(per, confine, checkDepartPermit(model.oldDepartId, "add"), out strMsg);
            }
            if (op.Equals("refuse"))
            {
                //转换成实体
                model = (Chenxin.Lib.House.Entity.House_RequestChangeInfo)Chenxin.Lib.Utility.JsonHelp.Convert2Entity(context.Request["model"], typeof(Chenxin.Lib.House.Entity.House_RequestChangeInfo));
                if (model.RecordId == null)
                {
                    strMsg = "{success:0,msg:'获取请求数据失败！',data:''}";
                    return false;
                }
                model = Chenxin.Lib.House.DAL.House_RequestChangeInfo.GetModel(model.RecordId);
                if (model == null)
                {
                    strMsg = "{success:0,msg:'获取请求数据失败！',data:''}";
                    return false;
                }
                //加如权限项
                per.Add("ALL", Constants.Permit_RefuseRequest_All);
                per.Add("CITY", Constants.Permit_RefuseRequest_City);
                per.Add("COMPANY", Constants.Permit_RefuseRequest_Company);
                per.Add("DEPART", Constants.Permit_RefuseRequest_Department);
                //加入范围
                confine.Add("CityId", model.oldCity);
                confine.Add("CompanyId", model.oldCompanyId);
                confine.Add("OperatorId", model.oldUserId);
                //检查权限
                return CheckPermint(per, confine, checkDepartPermit(model.oldDepartId, "refuse"), out strMsg);
            }
        }
        strMsg = "{success:1,msg:'',data:{permit:true}}";
        return true;
    }


    //*******************************************
    //功能概要       ：部门内有无封盘解盘权限
    //参数説明       ：context 上下文
    //返回值説明     ：bool
    //功能詳細       ：部门内有无封盘解盘权限
    //作成者         ：chen.yugong 
    //作成日         ：2010-05-19
    //修改者         ：
    //修改日         ：
    //*******************************************
    public bool checkDepartPermit(Guid departId, string op)
    {
        //检查有无权限
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.AppendFormat(" (Departid = '{0}' AND  Userid= '{1}') ", departId, CurrentUserInfo.UserId);
        System.Collections.Generic.List<Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation> list = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetListArray(sb.ToString());
        if (list.Count > 0)
        {
            Chenxin.Lib.Hr.Entity.Struct_UserDepartRelation struct_UserDepartRelation = list[0];
            //作废委托
            if ("add".Equals(op) || "refuse".Equals(op))
            {
                return struct_UserDepartRelation.CanChangeConfirm;
            }
        }
        return false;
    }
    
    /// <summary>
    /// 权限检查，确定所拥有的操作
    /// 添加人：chenyugong
    /// 添加日期：2010-06-13
    /// </summary>
    /// per ： 权限项
    /// confine：用户所在层级
    /// op：checkDepart 组织架构表中的设定
    /// strMsg：消息
    /// <returns>
    /// 返回true表示数据操作权限检查，程序将继续执行
    /// 返回false表示事先权限检查，程序自动跳出
    /// </returns>
    public bool CheckPermint(System.Collections.Hashtable per, System.Collections.Hashtable confine, bool checkDepart, out string strMsg)
    {
        //权限判断
        if (CurrentUserInfo.ContainsPermit(per["ALL"].ToString()))
        {
            strMsg = "{success:1,msg:'',data:{permit:true}}";
            return true;
        }
        else if (CurrentUserInfo.ContainsPermit(per["CITY"].ToString()))
        {
            if (CurrentUserInfo.CityId.Equals((Guid)confine["CityId"]))
            {
                strMsg = "{success:1,msg:'',data:{permit:true}}";
                return true;
            }
            else
            {
                strMsg = "{success:1,msg:'操作失败，您无此权限，请联系管理员！',data:{permit:false}}";
                return false;
            }
        }
        else if (CurrentUserInfo.ContainsPermit(per["COMPANY"].ToString()))
        {
            if (CurrentUserInfo.CompanyId.Equals((Guid)confine["CompanyId"]))
            {
                strMsg = "{success:1,msg:'',data:{permit:true}}";
                return true;
            }
            else
            {
                strMsg = "{success:1,msg:'操作失败，您无此权限，请联系管理员！',data:{permit:false}}";
                return false;
            }
        }
        else if (CurrentUserInfo.ContainsPermit(per["DEPART"].ToString()))
        {
            if (checkDepart)
            {
                strMsg = "{success:1,msg:'',data:{permit:true}}";
                return true;
            }
            else
            {
                strMsg = "{success:1,msg:'操作失败，您无此权限，请联系管理员！',data:{permit:false}}";
                return false;
            }
        }
        else
        {
                strMsg = "{success:1,msg:'操作失败，您无此权限，请联系管理员！',data:{permit:false}}";
                return false;
        }
    }
}